#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<string>
using std::cout;
using std::cin;
using std::endl;
#include"list.hpp"
using namespace wcz;

int main() 
{
	list<int> l1;
	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(4);
	l1.push_back(5);
	l1.push_back(6);

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;


	l1.pop_back();
	l1.pop_back();
	l1.pop_back();

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;

	l1.push_back(1);
	l1.push_back(2);
	l1.push_back(3);
	l1.push_back(5);
	l1.push_back(5);
	l1.push_back(5);

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int>::iterator it = l1.begin();
	while ( it != l1.end())
	{
		if (*it == 5)
		{
			it = l1.erase(it);
		}
		else
			++it;
	}

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;

	l1.insert(++l1.begin() , 9);
	l1.insert(++l1.begin(), 9);
	l1.insert(++l1.begin(), 9);
	l1.insert(++l1.begin(), 9);

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;

	l1.erase(++l1.begin());
	l1.erase(++l1.begin());
	l1.erase(++l1.begin());

	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int>l2(l1);
	l1.clear();
	
	cout << "l1 : ";
	for (auto e : l1)
	{
		cout << e << " ";
	}
	cout << endl;
	if (l1.empty())cout << "l1 is empty!" << endl;

	cout << "l2 : ";
	for (auto e : l2)
	{
		cout << e << " ";
	}
	cout << endl;

	list<int>l3(++l2.begin(),--l2.end());
	cout << "l3 : ";
	for (auto e : l3)
	{
		cout << e << " ";
	}
	cout << endl;
	cout << "l2 size==" << l2.size() << endl;
	cout << "l3 size==" << l3.size() << endl;

	cout << "l2 front==" << l2.front() << endl;
	cout << "l2 back==" << l2.back() << endl;

	cout << "l3 front==" << l3.front() << endl;
	cout << "l3 back==" << l3.back() << endl;

	return 0;
}